﻿using UnityEngine;
using System.Collections;


public class Moveoneway : MonoBehaviour 
{
    public Vector3 currentPosition, moveDirection = new Vector3(0,0,1), targetPosition;
    public float speed;
    private float t;


	// Use this for initialization
	void Start () 
    {
        currentPosition = transform.position;
        t = 2;
	}
	
	// Update is called once per frame
	void Update () 
    {
        t = Mathf.Clamp01(Time.deltaTime + t);
        transform.position = Vector3.MoveTowards(transform.position, targetPosition, Time.deltaTime * speed);
        if (transform.position == targetPosition)
        { //&& destroyMe){
            Destroy(this);
        }
    }
}
